import QtQuick 2.6
import QtQuick.XmlListModel 2.0
import Qt.labs.controls 1.0

StackView {
    id: skview
    signal checked(string address)

    initialItem:ListView {
        id: view
        model: XmlListModel{
            id: xmlModel
            source: "qrc:/data/area.xml"
            query: "/areas/area[type=2 and parent_id=1]"
            XmlRole { name: "name"; query: "name/string()" }
            XmlRole { name: "id"; query: "id/string()" }
        }
        delegate: Rectangle{
            width: view.width
            height: iHEIGHT * 1.5
            Label {
                text: model.name
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: iWIDTH
            }

            Rectangle {
                color: "gainsboro"
                width: parent.width
                height: 1
                anchors.bottom: parent.bottom
                visible: index != view.count - 1
            }

            MouseArea {
                anchors.fill: parent
                onClicked: skview.push("../lib/AddressCity.qml", {parent_id: model.id, areas: model.name})
            }
        }
    }
}
